package com.zhaolang.qogir.ui.adapter;

import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.zhaolang.qogir.ui.BaseFragment;
import com.zhaolang.qogir.ui.processed.FragmentProcessedCancel;
import com.zhaolang.qogir.ui.processed.FragmentProcessedDelivery;
import com.zhaolang.qogir.ui.processed.FragmentProcessedFinished;
import com.zhaolang.qogir.ui.processed.FragmentProcessedHurry;
import com.zhaolang.qogir.ui.processed.FragmentProcessedNew;
import com.zhaolang.qogir.ui.processed.FragmentProcessedReturn;

import java.util.ArrayList;
import java.util.List;

public class FragmentProcessedAdapter extends FragmentPagerAdapter {

    private String titleOption[] = {"新订单", "配送异常", "催单", "取消单", "配送完成"};

    private List<BaseFragment> listFragment = new ArrayList<BaseFragment>();

    public FragmentProcessedAdapter(FragmentManager fm) {
        super(fm);
        initFragmentList();
    }

    private void initFragmentList(){
        listFragment.add(0, new FragmentProcessedNew());
        listFragment.add(1, new FragmentProcessedDelivery());
        listFragment.add(2, new FragmentProcessedHurry());
        listFragment.add(3, new FragmentProcessedCancel());
        listFragment.add(4, new FragmentProcessedFinished());
    }

    @Override
    public Fragment getItem(int position) {
        if(position >=0){
            return listFragment.get(position);
        }else{
            return listFragment.get(0);
        }
    }

    @Override
    public int getCount() {
        return listFragment.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return titleOption[position];
    }
}
